package com.stm.bi.web;

import com.stm.bi.dto.cmd.SubjectAdd;
import com.stm.bi.dto.cmd.SubjectUpd;
import com.stm.bi.dto.query.SubjectPageQry;
import com.stm.bi.dto.vo.SubjectVO;
import com.stm.bi.dto.vo.SubjectCategoryInfoVO;
import com.stm.bi.service.SubjectService;
import com.stm.framework.annotation.Module;
import com.stm.framework.annotation.ReqParam;
import com.stm.framework.annotation.RestApi;
import com.stm.framework.dto.Response;
import com.stm.framework.model.CustomizePage;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
* 科目-controller服务
*
* @author qinyongjie
* @date 2025-05-22
*/
@RestController
@RequestMapping("/subject")
@Module("科目")
public class SubjectController {
    @Resource
    private SubjectService subjectService;


    /**
    * 科目分页列表
    */
    @GetMapping(value = "/selectPage")
    @RestApi(name = "科目分页列表", author = "qinyongjie", idx=1)
    public Response<CustomizePage<SubjectVO>> selectPage(SubjectPageQry subjectPageQry) {
        return subjectService.selectPage(subjectPageQry);
    }

    /**
    * 科目详细查询
    */
    @GetMapping(value = "/{id}")
    @RestApi(name = "科目详细查询", author = "qinyongjie", idx=2)
    public Response<SubjectVO> selectById(@PathVariable("id") @ReqParam(label = "id",required = true) Long id) {
        return subjectService.selectById(id);
    }

    /**
    * 科目新增
    */
    @PostMapping(value = "/create")
    @RestApi(name = "新增科目", author = "qinyongjie", idx=3)
    public Response create(@RequestBody SubjectAdd subjectAdd) {
        return subjectService.create(subjectAdd);
    }

    /**
    * 科目更新
    */
    @PutMapping(value = "/update")
    @RestApi(name = "更新科目", author = "qinyongjie", idx=4)
    public Response update(@RequestBody SubjectUpd subjectUpd) {
        return subjectService.update(subjectUpd);
    }

    /**
     * 通过归属分类ID查询科目信息
     */
    @GetMapping(value = "/selectByCategoryId")
    @RestApi(name = "通过归属分类ID查询科目信息", author = "qinyongjie", idx=5)
    public Response<List<SubjectCategoryInfoVO>> selectByCategoryId(@RequestParam("categoryId") @ReqParam(label = "归属分类ID", required = true) Long categoryId) {
        return subjectService.selectByCategoryId(categoryId);
    }
}